<%@page import="com.shsh.safemanage.dao.ProblemDao"%>
<%@page import="com.shsh.safemanage.action.UserAction"%>
<%@page import="com.shsh.safemanage.dao.UserDao"%>
<%@page import="com.shsh.safemanage.util.RequestUtil"%>
<%@ page language="java" pageEncoding="UTF-8"%>
<%@page import="java.util.List"%>
<%@page import="java.util.Map"%>
<%@page import="java.util.HashMap"%>
<%@page import="com.shsh.safemanage.action.PostcheckReportAction"%>
<%@page import="com.shsh.safemanage.action.ActionCreator"%>
<%@page import="com.shsh.safemanage.model.Department1"%>
<%@page import="com.shsh.safemanage.model.PostCheck"%>
<%@page import="com.shsh.safemanage.model.Problem"%>
<%@page import="com.shsh.safemanage.model.PostcheckDepartMonthCheckSummaryReport"%>
<%@page import="com.shsh.safemanage.model.PostcheckDepartMonthCheckSummaryRow"%>
<%@page import="com.shsh.safemanage.model.User"%>
<%@page import="com.shsh.safemanage.dao.PostCheckDao"%>
<%@page import="com.shsh.safemanage.dao.DaoCreator"%>
<%@page import="com.shsh.safemanage.util.Constants"%>
<%@page import="com.shsh.safemanage.util.Util"%>
<%
{
Long problemID = RequestUtil.getParameter(request, Constants.REQUEST_PARAMETER_ID, (Long)null);
	
User sessionUser = (User)session.getAttribute(Constants.SESSION_USER);
	
PostcheckReportAction reportAction = ActionCreator.createPostcheckReportAction();
UserAction userAction = ActionCreator.createUserAction();

PostCheckDao thePostcheckDao = DaoCreator.createPostCheckDao();
ProblemDao problemDao = DaoCreator.createProblemDao();
UserDao userDao = DaoCreator.createUserDao();

Problem problem = problemDao.getProblemByID(problemID);
PostcheckDepartMonthCheckSummaryReport reportTable = thePostcheckDao.getMonthCheckSummaryReportByProblemID(problemID);

int year = reportTable.getYear();
int month  = reportTable.getMonth();

String fromPage = request.getParameter(Constants.REQUEST_PARAMETER_FROM_PAGE);
if(fromPage == null){
	fromPage = "user_info.jsp";
} else if(fromPage.equals("problemsTobeProcessed")){
	fromPage = "problems_tobe_processed.jsp";
} else if (fromPage.equals("yiban")) {
	fromPage = "problem_browse.jsp";
} else {
	fromPage = "user_info.jsp";
}
%>
<div class="hider" id="hider">
	<span>&nbsp;</span>
</div>
<div class="position">
	<img src="images/position2.jpg" style="padding: 7px 9px; float: left;" />当前位置：上海高桥分公司问题管理平台 &gt;&gt; 岗检汇总统计 &gt;&gt;作业部<%=month %>月岗检考核汇总表
</div>
<div class="tt">《作业部月岗检考核汇总表》</div>
<div class="content" style="">
	<div style="width:97%;margin-left: 10px;font-weight:bold;font-size:20; ">
	<span style="margin-right: 20px;float:right;">
		月份：<%=reportTable.getYear() %>年<%=reportTable.getMonth() %>月
	</span>
	</div>
	<table border="1" width="97%" style="align:center; margin-left: 6px">
	<tr>
		<td rowspan="2" style="text-align:center;width:4%;" class="td3">
		序号
		</td>
		<td rowspan="2" style="text-align:center;width:10%;" class="td3">
		岗检管理线条
		</td>
		<td rowspan="2" style="text-align:center;width:12%;" class="td3">
		作业部
		</td>
		<td rowspan="2" style="text-align:center;width:12%;" class="td3">
		装置
		</td>
		<td rowspan="2" style="text-align:center;width:6%;" class="td3">
		扣分分值
		</td>
		<td rowspan="2" style="text-align:center;width:16%;" class="td3">
		扣分原因
		</td>
		<td colspan="2" style="text-align:center;" class="td3">
		作业部反馈信息
		</td>
		<td rowspan="2" style="text-align:center;width:8%;" class="td3">
		问题流转状态
		</td>
		<td rowspan="2" style="text-align:center;width:8%;" class="td3">
		岗检管理线条问题汇总
		</td>
	</tr>
	<tr>
		<td style="text-align:center;width:11%;"  class="td3">
		考核落实情况
		</td>
		<td style="text-align:center;width:9%;"  class="td3">
		是否整改
		</td>
	</tr>
	
	<%
	List<PostcheckDepartMonthCheckSummaryRow> rowList = reportTable.getRowList();
	for(int i = 0; i< rowList.size();i++) {
		PostcheckDepartMonthCheckSummaryRow row = rowList.get(i);
		List<Problem> problemList = row.getProblemList();
		PostCheck postcheck = row.getPostcheck();
		boolean orderDisplayed = false;
		for (Problem p : problemList) {
			String userTransferFeedbackStr = userAction.getUserTransferFeedbackStr(problemDao.getLatestProblemTransferFeedbackByProblemID(p.getId()));
			p.setUserTransferFeedbackStr(userTransferFeedbackStr);
	%>
	<tr>
		<%
		if(!orderDisplayed) {
		%>
		<td style="text-align:center;" rowspan="<%=problemList.size()%>">
			<%=(i+1) %>
		</td>
		<td style="text-align:center;" rowspan="<%=problemList.size()%>">
			<%=postcheck.getCheckName() %>
		</td>
		<%
		}
		%>
		<td style="text-align:center;">
		<%=reportTable.getDepart1Name() %>
		</td>
		<td style="text-align:center;">
		<%=p.getEquipmentName() %>
		</td>
		<td style="text-align:center;">
		<%=p.getGrade()==null?"&nbsp;":Util.formatGrade(p.getGrade()) %>
		</td>
		<td style="text-align:center;">
		<%=Util.getDisplay(p.getProblemContent(), "&nbsp;")%>
		</td>
		<td style="text-align:center;">
		<%=Util.isNullOrEmpty(p.getCloseFeedback())?"&nbsp;":p.getCloseFeedback() %>
		</td>
		<td style="text-align:center;">
			<input disabled="disabled" id="ClosedTrue<%=p.getId() %>" name="ClosedTrue<%=p.getId() %>" type="checkbox" value="true"  <%=p.getIsClosed()?"checked=\"checked\"":"" %> onclick="checkClosedTrue(<%=p.getId() %>)" /><label for="ClosedTrue<%=p.getId() %>">是</label>
			<input disabled="disabled" id="ClosedFalse<%=p.getId() %>" name="ClosedFalse<%=p.getId() %>" type="checkbox" value="false"  <%=!p.getIsClosed()?"checked=\"checked\"":"" %>onclick="checkClosedFalse(<%=p.getId() %>)" /><label for="ClosedFalse<%=p.getId() %>">否</label>
		</td>
		<td style="text-align:center;">
			<%=p.getUserTransferFeedbackStr()%>
		</td>
		<%
		if(!orderDisplayed) {
		%>
		<td style="text-align:center;" rowspan="<%=problemList.size()%>">
			<%=problemList.size() %>
		</td>
		<%
		orderDisplayed = true;
		
		}
		
		}
		%>
	</tr>
	<%
	}
	%>
	<tr>
		<td colspan="2" style="text-align:center;"  class="td3">
		合计考核分
		</td>
		<td style="text-align:center;">
		<%=reportTable.getGradeSum()==null?"&nbsp;":Util.formatGrade(reportTable.getGradeSum()) %>
		</td>
		<td colspan="2"  style="text-align:center;"  class="td3">
		考核金额（元）：
		</td>
		<td style="text-align:center;">
		<%=Util.formatGrade(reportTable.getPenaltySum())%>
		</td>
		<td style="text-align:center;"  class="td3">
		已整改计数
		</td>
		<td style="text-align:center;">
		<%=Util.getDisplay(reportTable.getClosedCount(), "&nbsp;")%>
		</td>
		<td style="text-align:center;"  class="td3">
		问题数量
		</td>
		<td style="text-align:center;">
		<%=Util.getDisplay(reportTable.getProblemCount(), "&nbsp;")%>
		</td>
	</tr>
	<tr>
		<td class="td3" colspan="2" style="text-align:center;" >
			汇总人
		</td>
		<td style="text-align:center;">
		<%=problem.getWriteUserName() %>
		</td>
		<td class="td3" colspan="2" style="text-align:center;" >
			汇总日期
		</td>
		<td style="text-align:center;">
			<%=Util.formatDate(problem.getWriteTime()) %>
		</td>
		<td class="td3" style="text-align:center;" >
			负责人
		</td>
		<td style="text-align:center;">
		<%
			String closeUserName = null;
			if(problem.getCloseUserID() !=null ){
				User user = userDao.getUserByID(problem.getCloseUserID());
				closeUserName = user.getName();
			}
		%>
		<%=Util.getDisplay(closeUserName, "&nbsp;") %>
		<%
		%>
		</td>
		<td class="td3" style="text-align:center;" >
			确认日期
		</td>
		<td style="text-align:center;">
			<%=problem.getCloseTime() == null? "&nbsp;":Util.formatDate(problem.getCloseTime()) %>
		</td>
	</tr>
	<tr>
		<td class="td1" height="35" colspan="10" style="padding-top:15px;padding-bottom:15px;">
			<input type="button" style="margin-left: 45%;" value="取 消" onclick="cancelWrite()" />
		</td>
	</tr>
	</table>
</div>
<script type="text/javascript">
function cancelWrite(){
	loadPageSection('<%=request.getContextPath()%>/<%=fromPage%>', 'mainContentDiv');
}
</script>
<%
}// end of page
%>